<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>axios</title>
    <script src="vue3.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>
    <div id="app">
        <button @click="loaddata">点击加载</button>
        <ul>
            <li>姓名 年龄</li>
            <li v-for="item in stus">{{item.name}} {{item.age}}</li>
        </ul>
    </div>
    <script>
        const {createApp} = Vue
        createApp({
            data(){
                return{
                    stus:[]
                }
            },
            methods:{
                // loaddata(){
                //     const that = this
                //     axios.get("./stus.json").then(function (res){
                //         console.log(that)
                //         // console.log(res.data.data)
                //         that.stus = res.data.data
                //     })
                // },
                loaddata(){
                    axios.get("./stus.json").then(res => {
                        this.stus = res.data.data
                    })
                }
            }
        }).mount('#app')
    </script>
</body>
</html>